<?php
namespace App\Params\H5;
use App\Params\Param;
/**
 * 优惠券列表查询参数
 *
 * @author: WangBin
 * @date: 2021/7/26
 * @mail: <849850352@qq.com>
 */
class GoodsListParams extends Param
{
    public $keywords;
    public $category_id = 0;
    public $page_size = 20;
    public $page = 1;
    public $sort_by = 'all';
    public $sort_type = 'desc';

    public function rules()
    {
        return [
            'keyword' => 'nullable|string',
            'category_id' => 'nullable|integer',
            'page_size' => 'integer|max:0',
            'page' => 'integer|min:0',
            'sort_by' => 'string|in:all,sales,price',
            'sort_type' => 'string|in:asc,desc'
        ];
    }

    /**
     * @return mixed
     */
    public function getKeywords()
    {
        return $this->keywords;
    }

    /**
     * @param mixed $keyword
     */
    public function setKeywords($keywords): void
    {
        $this->keywords = $keywords;
    }

    /**
     * @return int
     */
    public function getCategoryId(): int
    {
        return $this->category_id;
    }

    /**
     * @param int $category_id
     */
    public function setCategoryId(int $category_id): void
    {
        $this->category_id = $category_id;
    }

    /**
     * @return int
     */
    public function getPageSize(): int
    {
        return $this->page_size;
    }

    /**
     * @param int $page_size
     */
    public function setPageSize(int $page_size): void
    {
        $this->page_size = $page_size;
    }

    /**
     * @return int
     */
    public function getPage(): int
    {
        return $this->page ? -- $this->page : 0;
    }

    /**
     * @param int $page
     */
    public function setPage(int $page): void
    {
        $this->page = $page;
    }

    /**
     * @return string
     */
    public function getSortBy(): string
    {
        return $this->sort_by;
    }

    /**
     * @param string $sort_by
     */
    public function setSortBy(string $sort_by): void
    {
        $this->sort_by = $sort_by;
    }

    /**
     * @return string
     */
    public function getSortType(): string
    {
        return $this->sort_type;
    }

    /**
     * @param string $sort_type
     */
    public function setSortType(string $sort_type): void
    {
        $this->sort_type = $sort_type;
    }
}